package cn.com.dashihui.api.rabbitmq;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import com.jfinal.kit.PropKit;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class MQFactory {
	
	public static Connection getConnection(){
		
		ConnectionFactory factory =new ConnectionFactory();
		factory.setPort(PropKit.getInt("rabbitMQ.port"));
		factory.setHost(PropKit.get("rabbitMQ.host"));
		factory.setUsername(PropKit.get("rabbitMQ.username"));
		factory.setPassword(PropKit.get("rabbitMQ.password"));
		factory.setVirtualHost(PropKit.get("rabbitMQ.virtualHost"));
		Connection connection = null;
		try {
			connection = factory.newConnection();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TimeoutException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return connection;
		
	}
	
	
}
